{extend name="extra@admin/content"}

{block name="content"}
<form onsubmit="return false;" action="{:url('add_edit')}" data-auto="true" method="post" class='layui-form' style='padding-top:20px'>

    <div class="layui-form-item">
        <label class="layui-form-label">文章标题</label>
        <div class="layui-input-block">
            {if $info and isset($info.title)}
            <input name="title" value='{$info.title|default=""}'
                   required="required" title="请输入文章标题" maxlength="100" placeholder="请输入文章标题" class="layui-input ">
            {else}
            <input name="title" value='{$info.title|default=""}' maxlength="100" required="required"
                   title="请输入文章标题" class="layui-input">
            {/if}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">文章内容</label>
        <div class="layui-input-block">
            <textarea name="content">{$info.content}</textarea>
            <script type="text/javascript">
            require(['ckeditor'], function () {
                var editor = window.createEditor('[name="content"]');
                // 设置内容
                // editor.setData('修改内容');
                // 获取内容
                var content = editor.getData();
                console.log(content);
            });
            </script>
            <script>
                layui.use('code', function () {
                    layui.code({encode: true});
                });
            </script>
        </div>
    </div>
    <div class="hr-line-dashed"></div>
    <div class="col-sm-4 col-sm-offset-2">
        {if isset($info['id'])}<input type='hidden' value='{$info.id}' name='id'/>{/if}
        {if isset($cate_id)}<input type='hidden' value='{$cate_id}' name='cate_id'/>{/if}
        <div class="layui-form-item text-center">
            <button class="layui-btn" type="submit">保存</button>
        </div>
    </div>
    <script type="text/javascript">
    layui.use('form', function(){
        var form = layui.form;      //只有执行了这一步，部分表单元素才会自动修饰成功
        form.render();
    });

</script>
</form>

{/block}